﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Radius.NET.Core.Service
{
    public class EleMenuOutput
    {
        /// <summary>
        /// Id
        /// </summary>
        public long Id { get; set; }

        /// <summary>
        /// 父Id
        /// </summary>
        public long Pid { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 路由地址
        /// </summary>
        public string Path { get; set; }

        /// <summary>
        /// 组件路径
        /// </summary>
        public string Component { get; set; }

        /// <summary>
        /// 重定向
        /// </summary>
        public string Redirect { get; set; }

        /// <summary>
        /// 菜单Meta
        /// </summary>
        public EleMenuMeta Meta { get; set; }

        /// <summary>
        /// 菜单子项
        /// </summary>
        public List<EleMenuOutput> Children { get; set; }
    }

    /// <summary>
    /// 菜单Meta配置
    /// </summary>
    public class EleMenuMeta
    {
        /// <summary>
        /// 标题
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// 图标
        /// </summary>
        public string Icon { get; set; }

        /// <summary>
        /// 是否隐藏
        /// </summary>
        public bool Hide { get; set; }

        /// <summary>
        /// 是否缓存
        /// </summary>
        public bool KeepAlive { get; set; }

    }

    /// <summary>
    /// 配置菜单对象映射
    /// </summary>
    public class EleMenuMapper : IRegister
    {
        public void Register(TypeAdapterConfig config)
        {
            config.ForType<SysMenu, EleMenuOutput>()
                .Map(t => t.Meta.Title, o => o.Title)
                .Map(t => t.Meta.Icon, o => o.Icon)
                .Map(t => t.Meta.Hide, o => o.Hide)
                .Map(t => t.Meta.KeepAlive, o => o.IsKeepAlive);
        }
    }
}
